package com.atguigu.exer2;

/*
（1）定义三角形类Triangle，
- 声明实例变量a,b,c，代表三角形三条边
- 声明无参构造 public Triangle()
- 声明有参构造public Triangle(double a, double b, double c)
  - 如果a,b,c的值无法构成三角形，给出错误体现，并且保留a，b，c为默认值0

 */
public class Triangle {
    public double a;
    public double b;
    public double c;

    public Triangle() {
    }

    public Triangle(double a, double b, double c) {
        //（1）边长不能为负数或0
        //（2）三角形要求任意两边之和大于第三边
        if(a<=0 || b<=0 || c<=0 || a+b<=c || b+c<=a ||a+c<=b){
            System.out.println(a+"," + b +"," + c +"的值无法构成三角形");
        }else {
            this.a = a;
            this.b = b;
            this.c = c;
        }
    }
   /* public Triangle(double a, double b, double c) {
        //（1）边长不能为负数或0
        //（2）三角形要求任意两边之和大于第三边
        if(a<=0 || b<=0 || c<=0 || a+b<=c || b+c<=a ||a+c<=b){
            System.out.println(a+"," + b +"," + c +"的值无法构成三角形");
            return; //结束当前构造器，构造方法，构造函数
        }
        this.a = a;
        this.b = b;
        this.c = c;
    }*/
}
